﻿function SearchKey() {
    var sear = $("#searchkey").val().trim();
    var url = location.href;
    var reg = /searchkey=.+\&?/;
    if (sear) {
        if (reg.test(url)) {
            location.href = url.replace(reg, "searchkey=" + sear);
        }
        else {
            location.href = "?searchkey=" + sear;
        }
    }
    else {
        if (reg.test(url)) {
            location.href = url.replace(reg, "");
        }
        else {
            location.reload();
        }
    }
}

function OnClickAgentListSearch() {
    SearchKey();
}

function OnClickUserReviewSearch() {
    SearchKey();
}

function OnClickComRebateSearch() {
    SearchKey();
}

function OnClickPromotionListSearch() {
    var sear = $("#txtStartTime").val().trim();
    var url = location.href;
    var reg = /StartTime=.+\&?/;
    if (sear) {
        if (reg.test(url)) {
            url = url.replace(reg, "StartTime=" + sear);
        }
        else {
            url += "?StartTime=" + sear;
        }
    }
   
    sear = $("#txtEndTime").val().trim();
    reg = /endTime=.+\&?/;
    if (sear) {
        if (reg.test(url)) {
            url = url.replace(reg, "endTime=" + sear);
        }
        else {
            url += "&endTime=" + sear;
        }
    }

    sear = $("#searchkey").val().trim();
    reg = /searchkey=.+\&?/;
    if (sear) {
        if (reg.test(url)) {
            url = url.replace(reg, "searchkey=" + sear);
        }
        else {
            url += "&searchkey=" + sear;
        }
    }
    else {
        if (reg.test(url)) {
            url = url.replace(reg, "");
        }
    }
    location.href = url;
}

$(".tab-content .imageThum img").click(function (e) {
    var img = $(this);
    var oHeight = img.height(); //取得图片的实际高度  
    if (50 == oHeight){
        img.width(500);
        img.height(500);
    }
    else {
        img.width(50);
        img.height(50);
    }
});